package cn.iocoder.yudao.module.erp.controller.admin.stock.vo.check;

import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat;
import cn.iocoder.yudao.framework.excel.core.convert.DictConvert;
import cn.iocoder.yudao.module.erp.dal.dataobject.stock.ErpStockCheckItemDO;
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
import com.alibaba.excel.annotation.ExcelProperty;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.NotNull;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;

import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.List;

import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
import static cn.iocoder.yudao.module.erp.enums.DictTypeConstants.AUDIT_STATUS;

@Schema(description = "管理后台 - ERP 库存盘点单 Response VO")
@Data
@ExcelIgnoreUnannotated
public class ErpStockCheckRespVO {

    @Schema(description = "盘点编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "11756")
    @ExcelProperty("盘点编号")
    private Long id;

    @Schema(description = "盘点单号", requiredMode = Schema.RequiredMode.REQUIRED, example = "S123")
    @ExcelProperty("盘点单号")
    private String no;

    @Schema(description = "合计数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "15663")
    private BigDecimal totalCount;

    @Schema(description = "合计金额，单位：元", requiredMode = Schema.RequiredMode.REQUIRED, example = "24906")
    private BigDecimal totalPrice;

    @Schema(description = "状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "10")
    @ExcelProperty(value = "状态", converter = DictConvert.class)
    @DictFormat(AUDIT_STATUS)
    private Integer status;

    @Schema(description = "备注", example = "随便")
    @ExcelProperty("备注")
    private String remark;

    @Schema(description = "附件 URL", example = "https://www.iocoder.cn/1.doc")
    private String fileUrl;

    @Schema(description = "创建人", example = "芋道")
    private Long creator;

    @Schema(description = "创建人名称", example = "芋道")
    @ExcelProperty("创建人")
    private String creatorName;

    @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
    @ExcelProperty("创建时间")
    private LocalDateTime createTime;

    @Schema(description = "盘点项列表", requiredMode = Schema.RequiredMode.REQUIRED)
    @ExcelProperty("盘点项列表")
    private List<Item> items;

//    @Schema(description = "产品信息", requiredMode = Schema.RequiredMode.REQUIRED)
//    @ExcelProperty("产品信息")
//    private String productNames;

    @Schema(description = "仓库等级（1一级库，2二级库）", requiredMode = Schema.RequiredMode.REQUIRED)
    @ExcelProperty("仓库等级（1一级库，2二级库）")
    private Integer warehouseLevel;

    @Schema(description = "仓库编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "6223")
    @ExcelProperty("仓库编号")
    private Long deptId;

    @Schema(description = "仓库名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "6223")
    @ExcelProperty("仓库名称")
    private String deptName;

    /**
     * 流程实例的编号
     */
    private String processInstanceId;

    /**
     * taskId
     */
    private String taskId;

    @Data
    public static class Item {

        @Schema(description = "盘点项编号", example = "11756")
        private Long id;

        @Schema(description = "仓库编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "3113")
        private Long deptId;

        @Schema(description = "产品编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "3113")
        private Long productId;

        @Schema(description = "产品规格", requiredMode = Schema.RequiredMode.REQUIRED)
        private String productStandards;

        @Schema(description = "产品销售单价", requiredMode = Schema.RequiredMode.REQUIRED, example = "100.00")
        private BigDecimal productPrice;

        @Schema(description = "账面数量（当前库存）", requiredMode = Schema.RequiredMode.REQUIRED, example = "100.00")
        @NotNull(message = "账面数量不能为空")
        private BigDecimal stockCount;

        @Schema(description = "实际数量（实际库存）", requiredMode = Schema.RequiredMode.REQUIRED, example = "100.00")
        @NotNull(message = "实际数量不能为空")
        private BigDecimal actualCount;

        @Schema(description = "盈亏数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "100.00")
        @NotNull(message = "盈亏数量不能为空")
        private BigDecimal rowcount;

        @Schema(description = "备注", example = "随便")
        private String remark;

        @Schema(description = "溢损类型", example = "1")
        private String addDelType;

        @Schema(description = "批次")
        private String productBatch;

        @Schema(description = "有效期", requiredMode = Schema.RequiredMode.REQUIRED)
        @ExcelProperty("有效期")
        private LocalDateTime productValidityDate;

        @Schema(description = "产品名称", example = "1")
        private String productName;

        @Schema(description = "产品单位编号")
        private Long productUnitId;

        @Schema(description = "产品单位")
        private String productUnitName;

        @Schema(description = "产品分类编号")
        private Long productCategoryId;

        @Schema(description = "产品分类名称")
        private String productCategoryName;

        @Schema(description = "产品采购价格")
        private BigDecimal productPurchasePrice;

        @Schema(description = "产品入库批次")
        private String inboundBatch;


        // ========== 关联字段 ==========

//        @Schema(description = "产品名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "巧克力")
//        private String productName;
//        @Schema(description = "产品条码", requiredMode = Schema.RequiredMode.REQUIRED, example = "A9985")
//        private String productBarCode;
//        @Schema(description = "产品单位名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "盒")
//        private String productUnitName;

    }


}